import React, { Component } from 'react';
/* 
  挂载
    
*/

class Deom extends Component{
  state={

  }
  static getDerivedStateFromProps(props,state){
    console.log(props)
    return {
      ...props
    }
  }
  render(){
    return <h1>Deom组件</h1>
  }
}
class App extends Component {
  state={

  }
  constructor(props){
    super(props);
    console.log("1.执行了App组件构造函数");
  }
  static getDerivedStateFromProps(props,state){
    console.log("2.执行getDerivedStateFromProps")
    // return null;  表示不会和当前状态合并
    return {
      ...props,
      msg:"🐂"
    }
  }
  render() {
    console.log("3.执行了render函数")
    return (
      <div>
        <Deom msg={"🐖"}></Deom>
      </div>
    );
  }
  componentDidMount(){
    console.log("4.执行componentDidMount")
  }
}

export default App;
